package usaco.c2009.november.bronze;

import java.util.Scanner;

/*
 * p3457
 * USACO 2009 November - Bronze
 */

public class p3457 {

	static int R;
	static int[][] m;

	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		R = scanner.nextInt();
		m = new int[R+1][R+1];
		int max = 0;
		for (int i=1;i<=R;++i) {
			for (int j=1;j<=i;++j) {
				m[i][j] = scanner.nextInt();
				if (i>1) {
					m[i][j] += Math.max(m[i-1][j], m[i-1][j-1]);
				}
				if (i==R) {
					if (m[i][j] > max) {
						max = m[i][j];
					}
				}
			}
		}
		System.out.println(max);

	}

}
